from django.db import models
from teacher.models import Teacher
from student.models import Student


# Create your models here.

class School(models.Model):
    name = models.CharField(max_length=128)
    nick = models.CharField(max_length=10, default="")
    desc = models.CharField(max_length=140, default="")
    shortcut = models.FileField(upload_to='shortcut/', default='shortcut/piano.jpg')
    location = models.CharField(max_length=128)
    detail = models.FileField(upload_to='files/', null=True)

    owner = models.ForeignKey('auth.User', on_delete=models.PROTECT, related_name="owner_schools", default=1)
    teachers = models.ManyToManyField(Teacher, related_name="teacher_schools", blank=True)
    students = models.ManyToManyField(Student, related_name="student_schools", blank=True)

    def __unicode__(self):
        return self.name
